clear all;
%控制点
P = [0 0; 1 1; 1.5 0.5; 1.5 -0.5; 1.25 0.3; 1 0; 1.25 -0.3; 1 -1];

%阶数
k=3;

%knots
NodeVector=U_disuniform(size(P,1)-1,k);

%type
type=4;%非均匀有理B样条 NURBS

%weights
weights=rand(size(P,1),1);
weights=weights/sum(weights);

%drawble
drawable=true;

%绘制spline曲线
BSpline(P,k,type,drawable,NodeVector,weights);
hold on

%给控制点按顺序打上标记
hold on
for i=1:size(P,1)
    text(P(i,1)+0.05,P(i,2),char(65+i-1));
end

%设置坐标轴标签和范围
figure(1)
xlabel('X','FontSize',20);
ylabel('Y','FontSize',20);
xlim([min(P(:,1))-0.2 max(P(:,1))+0.2]);
ylim([min(P(:,2))-0.2 max(P(:,2))+0.2]);